﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SnippetBox.Core.Common.Mvc.Validation;

namespace SnippetBox.Web.Models {
    public class RegisterModel {
        public RegisterModel(string username) {
            Username = username;
        }

        public RegisterModel() { }

        [Required(ErrorMessage = "Please fill in a username."), MaxLength(100), Remote("UsernameFree", "User", ErrorMessage = "Username already taken.", HttpMethod = "POST")]
        public string Username { get; set; }

        [Required(ErrorMessage = "Please fill in a password."), MaxLength(100), DataType(DataType.Password)]
        public string Password { get; set; }

        [Required(ErrorMessage = "Please confirm your password."), MaxLength(100), DataType(DataType.Password), Compare("Password", ErrorMessage = "Passwords do not match")]
        public string ConfirmPassword { get; set; }

        [DataType(DataType.EmailAddress), RegularExpressionAttribute(Regexps.EMAIL, ErrorMessage = "Invalid email address")]
        public string Email { get; set; }
    }
}